<template>
<!-- 钱包互转 -->
<div id="walletTransfer">
	<header class="mui-bar mui-bar-nav header">
		<div class="mui-icon mui-icon-left-nav mui-pull-left" @tap="$router.go(-1)"></div>
		<h1 class="mui-title">{{routerTitle}}</h1>
	</header>
	<div class="mui-content">
		<form class="mui-input-group">
			<div class="mui-input-row">
				<label>钱包选择</label>
				<select v-model="way" :style="way==0?'color:#999':''" class="mui-input-clear">
					<option value="0">请下拉选择</option>
					<option value="12">充值钱包转消费钱包</option>
					<option value="21">消费钱包转充值钱包</option>
					<option value="31">盈利钱包转充值钱包</option>
					<option value="32">盈利钱包转消费钱包</option>
					<!-- <option value="42">复投金额转消费钱包</option> -->
				</select>
			</div>
			<div class="mui-input-row">
				<label>转账金额</label>
				<input type="number" v-model="money" class="mui-input-clear" placeholder="请输入金额（元）">
			</div>
			<div class="mui-button-row">
				<button type="button" class="mui-btn mui-btn-primary" @tap="sureTransfer">确认</button>
				<button type="button" class="mui-btn mui-btn-danger" @tap="way='0';money=''">取消</button>
			</div>
		</form>
	</div>
</div>
</template>

<script>
import {centerToBet,betToCenter,profitToCenter,repeatedBetToBet,profitToBet} from "@/api/my"
export default{
	name:"walletTransfer",
	data(){
		return{
			way:"0",
			money:"",
		}
	},
	mounted(){
		if(this.$route.query.repeat) this.way="42"
	},
	methods:{
		sureTransfer(){
			if(this.way==0){
				mui.toast("请选择钱包")
				return;
			}
			
			if(this.money=="" || this.money==0){
				mui.toast("转账金额有误")
				return;
			}
			
			switch (this.way){
				case "12":
					centerToBet(this.money).then(res=>{
						if(res==200){
							mui.toast("转账成功")
							this.$router.go(-1)
						}else if(res.message){
							mui.toast(res.message)
						}else{
							mui.toast("系统错误")
						}
					})
					break;
				case "21":
					betToCenter(this.money).then(res=>{
						if(res==200){
							mui.toast("转账成功")
							this.$router.go(-1)
						}else if(res.message){
							mui.toast(res.message)
						}else{
							mui.toast("系统错误")
						}
					})
					break;
				case "42":
					repeatedBetToBet(this.money).then(res=>{
						if(res==200){
							mui.toast("转账成功")
							this.$router.go(-1)
						}else if(res.message){
							mui.toast(res.message)
						}else{
							mui.toast("系统错误")
						}
					})
					break;
				case "32":
					profitToBet(this.money).then(res=>{
						if(res==200){
							mui.toast("转账成功")
							this.$router.go(-1)
						}else if(res.message){
							mui.toast(res.message)
						}else{
							mui.toast("系统错误")
						}
					})
					break;
				default:
					profitToCenter(this.money).then(res=>{
						if(res==200){
							mui.toast("转账成功")
							this.$router.go(-1)
						}else if(res.message){
							mui.toast(res.message)
						}else{
							mui.toast("系统错误")
						}
					})
					break;
			}
		}
	}
}
</script>

<style scoped>
.mui-button-row button{
	margin: 0 5px;
}
</style>